//子项目展示js
var $dataTable;

function deleteTemplate(id) {
	if (id == null) {
		alert('id为空');
		return;
	}
	if (confirm('确定删除该模板信息吗?')) {
		var param = {};
		param.id = id;
		postContent("/template/delete", param, true, function(data) {
			if (data != null) {
				alert('删除成功!');
				$dataTable.ajax.reload();
			}
		});
	}
}

function downloadTemplate(id) {
	if (id == null) {
		alert('id为空');
		return;
	}
	window.location.href = "/template/downloadTemplate?id=" + id;
	return false
}

function showTemplateInit() {
	$dataTable = $('#option')
			.DataTable(
					getCommonPageParam(
							"/template/showPage",
							{},
							true,
							[ {
								"mData" : "name"
							}, {
								"mData" : "templateTypeStr"
							}, {
								"mData" : "download"
							}, {
								"mData" : "operation"
							} ],
							function(resp) {
								var data = resp.aaData;
								for (num in data) {
									var id = data[num].id;
									data[num].name = data[num].name ;
									data[num].templateType = data[num].templateType ;
									data[num].download = '<a href="#" onclick=downloadTemplate('
										+ id + ')>下载</a>';
									data[num].operation = '<a href="#" onclick=deleteTemplate('
											+ id + ')>删除</a>';
								}
								return resp;
							}));
}